<template>
  <div>
      <van-tabs v-model="active" :animated="true" :swipeable="true" sticky  @click="onClick">
        <van-tab title="功能应用">
          <application/>
        </van-tab>
        <van-tab title="推广公告">
          <apply-notice :list="list"/>
        </van-tab>
      </van-tabs>
    <apply-back/>
  </div>
</template>

<script>
import { homeData } from '../../common/common'
import { getNoticeList } from '../../network/home'
import Application from './childComps/Application.vue'
import ApplyBack from './childComps/ApplyBack.vue'
import ApplyNotice from './childComps/ApplyNotice.vue'
export default {
  name: "Apply",
  components: { 
    ApplyBack,
    Application,
    ApplyNotice,
  },
  data() {
    return {
      active: 2,
      list: [],
    }
  },
  created () {
    homeData();
  },
  methods: {
    getNotice() {
      getNoticeList().then(res => {
        if (res.state === "ok") {
          console.log(res.data)
          this.list = res.data
        } else if (res.msg === "no_login") {
          this.$router.replace("/login");
        }
      })
    },
    onClick(title) {
      if (title === 1) {
        this.getNotice()
      }
    }
  },
}
</script>

<style scoped>
.nav_control {
  width: 750px;
}
</style>